/ Assembly List / LJCWinFormCommon / FormCommon / SelectFile

Namespace - LJCWinFormCommon


Parameters
filter - The file filter.
initialDirectory - The initial selected directory.
defaultFileSpec - The default file specification.

Returns

The file specification. A null string if the "Cancel" button is selected.

Syntax

C#
public static String SelectFile(String filter, String initialDirectory = null, String defaultFileSpec = null)

Displays the Open dialog to select a file.

Example

C#
// No Spaces in filter file spec.
var filter = "csv files(*.csv)|*.csv|txt files(*.txt)|*.txt|All files(*.*)|*.*";
var initialDirectory = Directory.GetCurrentDirectory();
var inputFileSpec = FormCommon.SelectFile(filter, initialDirectory);
if (inputFileSpec != null)
{
  // Process File
}

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.